//10：用户输入出生日期（月-日），计算距离他的下个生日还有几天（注意：2月29的处理）
package Work0601;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class Birthday {

	public static void main(String[] args) throws ParseException {
		Scanner in = new Scanner(System.in);
		System.out.println("输入出生日期:");
		String a = in.next();
		SimpleDateFormat df = new SimpleDateFormat("MM-dd");
		Calendar t = Calendar.getInstance();
		t.setTime(df.parse(a));
		t.set(Calendar.YEAR, 2020);// 生日
		Calendar s = Calendar.getInstance();// 现在的时间
		int day;
		if (s.get(Calendar.DAY_OF_YEAR) <= t.get(Calendar.DAY_OF_YEAR)) {
			day = t.get(Calendar.DAY_OF_YEAR) - s.get(Calendar.DAY_OF_YEAR);
		} else {
			day = s.getActualMaximum(Calendar.DAY_OF_YEAR) - s.get(Calendar.DAY_OF_YEAR);
			t.set(Calendar.YEAR, t.get(Calendar.YEAR) + 1);
			day = day + t.get(Calendar.DAY_OF_YEAR);
		}
		System.out.println("还有" + day + "天过生日");

	}

}
